package vcp.client.GUI.factories;

import javax.swing.JPanel;

import vcp.client.GUI.mvc.view.addons.ActivityChartBarPanel;
import vcp.client.GUI.mvc.view.addons.PerformancePieChartPanel;
import vcp.client.interfaces.IVisitor;
import vcp.client.statistics.ActivityStatistics;
import vcp.client.statistics.PerformanceStatistics;
import vcp.client.statistics.StatisticsAbstract;

/**
 * 
 * @author VCP team
 *         <p>
 *         Statistics factory, by a given {@link StatisticsAbstract} statistics
 *         decides which chart to build
 *         </p>
 * 
 * @see IVisitor
 * @see StatisticsAbstract
 */
public class StatisticsChartFactory implements IVisitor
{
	/**
	 * 
	 * @param statistics
	 *            abstract statistics report
	 * @return {@link JPanel} containing statistics presentation
	 */
	public static JPanel createStatisticsChart ( StatisticsAbstract statistics )
	{
		StatisticsChartFactory factory = new StatisticsChartFactory();
		return statistics.acceptVisit(factory);
	}

	@Override
	public JPanel visit ( ActivityStatistics statistics )
	{
		return new ActivityChartBarPanel(statistics);
	}

	@Override
	public JPanel visit ( PerformanceStatistics performanceStatistics )
	{
		return new PerformancePieChartPanel(performanceStatistics);
	}

}
